<?php 
defined('_JEXEC') or die;
disablePageCaching();
// disable core styles to avoid bs conflict 
OC_Util::$core_styles = array();
if(isDevMode()) {
   OCP\Util::addStyle('company', 'company');
   OCP\Util::addStyle('jobposition', 'jobposition');
   OCP\Util::addScript('jobposition', 'jobposition');
   OCP\Util::addScript('jobposition', 'setup');
   OCP\Util::addScript('jobposition', 'foldermanage');
} else {
   OCP\Util::addStyle('static', 'company');
   OCP\Util::addStyle('static', 'jobposition');
   OCP\Util::addScript('static', 'apps/jobpos.min');
   OCP\Util::addScript('static', 'apps/jobpos.setup.min');
}
$lang = PFactory::getLanguage();
$lang->load("com_jobs", JPATH_SITE, "zh-CN");
OCP\App::setActiveNavigationEntry('jobpos_index');

$item = $_['jobdetails'];
$interviews = json_decode($item->online_interview_requirements);
?>
<script type="text/javascript" src="<?php print_unescaped(OC_Helper::linkTo('jobposition/js', 'jobposition.php'));?>"></script>

   <div class="hr_inner_navigate clearfix">
      <?php echo $_['part_position_toptab'];?>
      
      <div class="hr_breadcrumbs">当前位置：<a href="<?php echo OCP\Util::linkToRoute("jobpos_index");?>">职位管理</a> &gt; <?=strmaxwordlen($item->job_title,15)?>      
      <?php if (PCompanyHelper::checkCRUDPermission()): ?>
         <span style=" margin-left:30px;"><a href="<?php echo OC_Helper::linkToRoute("jobpos_postjob"); ?>" class="ppp_bluebtn brdb_publish">发布职位</a></span>
      <?php endif;?>
      </div>
      
   </div>
   
   <div id='jobcontent' class='hide' data-id='<?=$item->id?>' 
                                     data-jobtitle='<?=$item->job_title?>'></div>
   
   <div id="jobActionPanel" class="p_batchactionbox">
       <div class="p_batchaction_inner medium" style="text-align:center;">
          <span class="actions_change">
             <?php if($_['adminuser']):?>
                <?php if($item->is_trashed): ?>
                   <span class="selectedActions" style="display: inline-block;">
                      <a class="restore" href="javascript:;"><i class="restore"></i>恢复</a>
                   </span>
                <?php else: ?>
                   <span class="selectedActions" style="display: inline-block;">
                      <a class="delete" href="javascript:;"><i class="delete"></i>删除</a>
                   </span>
                   <span class="selectedActions" style="display: inline-block;">
                      <a class="infolder" href="javascript:;"><i class="infolder"></i>移入文件夹</a>
                   </span>
                <?php endif; ?>
             <?php endif; ?>
             <?php if(!$item->is_trashed): ?>
                <?php if($item->is_saved): ?>
                   <span class="selectedActions" style="display: inline-block;">
                      <a class="unsave noboxradius" href="javascript:;" title="点击取消收藏简历"><i class="save"></i>已收藏</a>
                   </span>
                <?php else: ?>
                   <span class="selectedActions" style="display: inline-block;">
                      <a class="save noboxradius" href="javascript:;" title="点击收藏简历"><i class="unsave"></i>未收藏</a>
                   </span>
                <?php endif; ?>
             <?php endif; ?>
          </span>
       </div>
   </div>

   <div id="jobdemands" class="hr_position_set hr_position_set_inner" style="padding-top:0px;">
      <div class="hr_position_thename yahei"><?=strmaxwordlen($item->job_title,15)?>
        <?php if($_['edit']): ?>
           <?php if($item->num_applied == 0): ?>
           <a class="songti" style="color:#999;"><?=$item->num_applied?>人申请</a>
           <?php else: ?> 
           <a href="<?php echo OC_Helper::linkToRoute("resumes_jobpos", array('jobid'=>$item->id)); ?>" class="songti"><?=$item->num_applied?>人申请<span class="ie9roundedgradient"><span class="fonddetail songti">查看</span></span></a>           
           <?php endif; ?>
           <?php
              $offsitesearchurl = OC_Helper::linkToRoute('resumes_offsitesearch').'?new=1&jobid='.$item->id.'&jobtitle='.JFilterOutput::stringURLUnicodeSlug($item->job_title);
           ?>
           <a target="_blank" href="<?php echo $offsitesearchurl;?>" class="offsitesar_josbtn offsitesearch" title="根据此职位条件搜索简历"></a>
        <?php endif; ?>
      </div>

      <?php
      $adminNameArr = array();
      $adminUsers = PCompanyHelper::getJobAdminUser($item->id, 6);
      if(!empty($adminUsers)) {
         $i=0;
         foreach ($adminUsers as $adminUser) {
            if($i==5) {
               $adminNameArr[] = '...';
               break;
            }

            $adminNameArr[] = $adminUser['displayname'];
            $i++;
         }
      }
      ?>
      
      <?php if($_['edit']): ?>
      <div class="dropdown selectmanager medium">招聘管理员：<span id="jobmanagername"><?=(empty($adminNameArr) ? "--" : implode("、", $adminNameArr));?></span>
        <?php if(PFactory::isMasterUser()): ?>
        <a href="javascript:;" id="selectjobmanager" class="dropdown-toggle btn" data-target="#">选择</a>
        <?php endif; ?>
      </div>
      
      <div id="jobmanagerlist" class="popup" style="display:none; position:absolute;">
         <div class="modal changeinterview_dialog feedback_dialog">
            <div class="topsj"></div>
            <div class="modal-header clearfix">
               <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
               <a href="<?php echo OC_Helper::linkToRoute("company_subaccounts");?>" class="btn btn_feedback">创建子账号</a>
               <h3 class="songti">选择招聘管理员</h3>
            </div>
            <div id="jobmanagerlistbody" class="modal-body medium">
            </div>
         </div>
      </div>

         <?php
            $interviews = json_decode($item->online_interview_requirements);
         ?>
         <div class="hr_editposition">
         	<div class="hr_edittitle">
               <b>招聘设置</b>
               <span id="invitesetting" style="display:<?=((empty($interviews->onlinetest) && empty($interviews->persontest)) ? "none": "inline")?>">
               <label class="checkbox inline medium">
                  <input <?=(isset($item->auto_invite) && $item->auto_invite ? "checked" : "")?> class="auto_invite" type="checkbox"/>
                  <em style="cursor:pointer; color:#333333;">自动邀请笔试评测</em>
               </label> 
               <span class="level_explan">
                  <div class="hr_net_tipdialog jobpos_tip">
                     <div class="hr_net_point"></div>
                     <div class="hr_net_tipcontent medium">
                           <span style="color:#666666;">自动邀请应聘者完成线上笔试、性格评测。如取消勾选，您将需要在简历管理中手动通知应聘者，否则云招聘将无法为您进行匹配度计算和人才筛选。</span>
                     </div>
                  </div>
                </span>
               <em class="medium" style="color:#999999; margin-left:3px;">(如取消勾选, 您将需要手动通知应聘者完成线上笔试、性格评测)</em>
               </span>
            </div>
            
            <div class="hr_settingwrap">
               <?=$_['jobpos_head']?>
            </div>
         </div>
         <?php if(empty($interviews->onlinetest) && empty($interviews->persontest)): ?>
            <div class="hr_position_top5 hr_uploadfile notdone" id="invitefirstok">
            <div class="hr_position_top5inner">
            <div class="closediv"></div>
            <div class="uploadfiledilog">
                <img src="/images/3/up_employopen.png"/>
                <br/>
                <label class="checkbox inline medium" style="margin-top:-10px;">
                  <input <?=($item->auto_invite ? "checked" : "")?> class="auto_invite" type="checkbox"/>
                  <em style="cursor:pointer; color:#333333">自动邀请笔试评测</em>
                </label>
                <span class="level_explan" style="margin-left:5px;">
                  <div class="hr_net_tipdialog jobpos_tip">
                     <div class="hr_net_point"></div>
                     <div class="hr_net_tipcontent medium">
                        <span style="color:#666666;">自动邀请应聘者完成线上竞聘流程。如取消勾选，您将需要在简历管理中手动通知应聘者，否则云招聘将无法为您进行匹配度计算和人才筛选。</span>
                     </div>
                  </div>
               </span>
               <em class="medium dialogborderbottom" style="color:#999999; margin-left:3px;">(如取消勾选, 您将需要手动通知应聘者完成线上笔试、性格评测)</em>
               您可以继续设置：
                  <a id="goonlinetest" href="#onlinetest">线上笔试</a>
                  <a id="gopersontest" href="#persontest">性格评测</a>
            </div>
            </div>
            </div>
         <?php endif; ?>

         
      <?php endif; //adminuser ?>
          <?=$_['part_jobdetails']?>
      <span id="job_id" class="jobid" style="display:none;"><?=$item->id?></span>
   </div>  
   
   <?=$_['part_position_modal']?>
